<%@ page import="com.wuming.caiwu.security.SecurityHander" %><%--
  Created by IntelliJ IDEA.
  User: zengyao
  Date: 2018/6/30
  Time: 14:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/share/taglib.jsp" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <title>会员信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style>
        .layui-upload button {
            background: none;
            position: absolute;
            top: 10px;
            left: 110px;
            width: 82px;
            height: 82px;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body style="background-color: #f0f2f5;">
<div style="padding: 15px;margin: 15px;background-color: #fff;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>会员基本信息</legend>
    </fieldset>
    <form class="layui-form" id="editUser">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 120px">昵称</label>

                <div class="layui-input-inline">
                    <input name="nickname" class="layui-input" type="text" autocomplete="off" placeholder="请输入昵称"
                           value="${member['nickname']}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 120px">手机号码</label>

                <div class="layui-input-inline">
                    <input name="phone" class="layui-input" type="tel" autocomplete="off" placeholder="请输入手机号码"
                           value="${member['phone']}">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 120px">角色</label>

                <div class="layui-input-inline">
                    <select name="roleId" id="roleId" lay-verify="roleId">
                        <option value="">请选择</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 120px">余额</label>

                <div class="layui-input-inline">
                    <input name="blance" class="layui-input" type="text" autocomplete="off" placeholder="请输入余额"
                           value="${member['blance']}">
                </div>
            </div>
        </div>

        <div class="layui-row" style="text-align: center;">
            <button class="layui-btn layui-btn-normal" type="button" name="btnSave" id="saveUser">保存信息</button>
        </div>
        <input type="hidden" name="id" value="${member['id']}"/>
    </form>

    <script src="${allServerPath}static/layui/layui/layui.js"></script>
    <script>
        layui.use(['form', 'layedit', 'laydate', 'jquery', 'upload'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , $ = layui.jquery
                , upload = layui.upload;

            laydate.render({
                elem: '#expireTime'
            });

            $(document).ready(function () {
                getAllRole();
            });

            function getAllRole() {
                $.ajax({
                    type: 'get',
                    url: '${allServerPath}web/sysrole/getAll.htmls',
                    data: {
                        memberId: '<%=SecurityHander.getCurrentUserId()%>'
                    },
                    dataType: 'JSON',
                    success: function (obj) {
                        if (obj.success) {
                            $.each(obj.data, function (index, item) {
                                var s = "<option value='" + item.id + "'>" + item.name + "</option>";
                                $("#roleId").append(s);
                            })
                            var roleId = '${member.roleId}';
                            $("#roleId").val(roleId);
                            form.render();
                        }
                    }
                });
            }

            $("#saveUser").click(function () {
                $.ajax({
                    type: "post",
                    url: "${allServerPath}/web/ums/save.htmls",
                    data: $('#editUser').serialize(),// 你的formid
                    dataType: "JSON",
                    success: function (data) {
                        if (data.success) {
                            layer.msg("保存成功.");
                        } else {
                            layer.msg("保存失败,请稍后重试.");
                        }
                    },
                    error: function (msg) {
                        layer.msg("保存失败.");
                    }
                });
            });

        });
    </script>
</div>

</body>
</html>
